/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package savet.gui.controllers;

import savet.gui.util.IUtilTabela;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.openswing.swing.message.receive.java.Response;
import org.openswing.swing.message.receive.java.VOListResponse;
import org.openswing.swing.message.receive.java.ValueObject;
import org.openswing.swing.table.client.GridController;
import org.openswing.swing.table.java.GridDataLocator;
import savet.entidades.Trabalhador;

/**
 *
 * @author Rafael
 */
public class GuiSAVETController extends GridController implements GridDataLocator {

    private List<Trabalhador> listaTrabalhadores;
    private IUtilTabela utilTabela;

    public Response loadData(int action, int startIndex, Map filteredColumns, ArrayList currentSortedColumns, ArrayList currentSortedVersusColumns, Class valueObjectType, Map otherGridParams) {
        VOListResponse listResponse = new VOListResponse();
        listResponse.setRows(listaTrabalhadores);
        return listResponse;
    }

    @Override
    public Response insertRecords(int[] rowNumbers, ArrayList newValueObjects) throws Exception {
        VOListResponse listResponse = new VOListResponse();
        for (Object object : newValueObjects) {
            listaTrabalhadores.add((Trabalhador) object);
        }
        listResponse.setRows(newValueObjects);
        return listResponse;
    }

    public List<Trabalhador> getListaTrabalhadores() {
        return listaTrabalhadores;
    }

    public void setListaTrabalhadores(List<Trabalhador> listaTrabalhadores) {
        this.listaTrabalhadores = listaTrabalhadores;
    }

    @Override
    public void selectedCell(int rowNumber, int columnIndex, String attributedName, ValueObject persistentObject) {

        utilTabela.selectRowAllTables(rowNumber);
        super.selectedCell(rowNumber, columnIndex, attributedName, persistentObject);
    }

    public IUtilTabela getUtilTabela() {
        return utilTabela;
    }

    public void setUtilTabela(IUtilTabela utilTabela) {
        this.utilTabela = utilTabela;
    }
    
}
